<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE HTML>
<html>
<head>
    <title>Home</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="keywords" content=""/>
    <%@include file="../my_js_css/cssInclude.jsp" %>

    <script type="application/x-javascript"> addEventListener("load", function () {
        setTimeout(hideURLbar, 0);
    }, false);

    function hideURLbar() {
        window.scrollTo(0, 1);
    } </script>

</head>
<body>
<div class="page-container">
    <!--/content-inner-->
    <div class="left-content">
        <div class="inner-content">
            <!-- header-starts -->
            <div class="header-section">
                <!--menu-right-->
                <div class="top_menu" style="height: 80px; text-align: center;">
                    <span style="display: inline-block; line-height: 80px; font-size: 30px; font-weight: 600; color: #fff">
                         智慧旅游
                    </span>
                    <a style=" float: right; color: #fff; margin: 26px 23px 0 0; font-size: 19px;" class="tooltips" href="/Tourism">
                        <i class="lnr lnr-power-switch"></i>
                    </a>
                    <div class="clearfix"></div>
                </div>
                <!--//menu-right-->
                <div class="clearfix"></div>
            </div>
            <!-- //header-ends -->
            <!--outter-wp-->
            <div class="outter-wp">
                <!--sub-heard-part-->
                <div class="sub-heard-part">
                    <ol class="breadcrumb m-b-0">
                        <li><a href="index.html">系统管理</a></li>
                        <li class="active">部门管理</li>
                    </ol>
                </div>
                <!--//sub-heard-part-->
                <div class="graph-visual tables-main">
                    <div class="graph">
                        <div class="form-group">
                            <a class="btn blue"
                               style="float: right; padding: 8px 14px; font-size: 15px;"> <div onclick="clearModel()">新增</div></a>

                        </div>
                        <div class="tables">
                            <style>
                                .table > thead > tr > th {
                                    text-align: center;
                                }

                                .table td {
                                    text-align: center;
                                }

                                .table > tbody > tr > td, .table > tbody > tr > th, .table > tfoot > tr > td, .table > tfoot > tr > th, .table > thead > tr > td, .table > thead > tr > th {
                                    vertical-align: initial;
                                    text-align: center;

                                }

                                .table > tbody > tr > td, .table > tbody > tr > th, .table > tfoot > tr > td, .table > tfoot > tr > th {
                                    padding: 0px !important;
                                }

                            </style>
                            <table class="table table-bordered" style="text-align: center;">
                                <thead>
                                <tr>
                                    <th>序号</th>
                                    <th>部门名称</th>

                                    <th>操作</th>

                                </tr>
                                </thead>
                                <tbody id="emps">
                                <c:forEach items="${orgs}" var="org" varStatus="status">
                                    <tr>
                                        <th scope="row">${ status.index + 1}</th>

                                        <td>${org.org_name}</td>

                                        <td><a class="btn green" style=" padding: 6px 12px; font-size: 14px;"> <div onclick="edit(${org.org_id})">修改</div></a><a
                                                class="btn red" style=" padding: 6px 12px; font-size: 14px;">   <div onclick="del(${org.org_id})">删除</div></a></td>
                                    </tr>
                                </c:forEach>
                                </tbody>
                            </table>

                        </div>

                    </div>

                </div>
                <!--//graph-visual-->
            </div>
            <!--//outer-wp-->
            <!--footer section start-->

        </div>
    </div>
    <!--//content-inner-->
    <!--/sidebar-menu-->
    <div class="sidebar-menu">
        <header class="logo">
            <a href="#" class="sidebar-icon"> <span class="fa fa-bars"></span> </a>
            <a href="${ctx}/sys/index "> <span id="logo"> <h1>智慧旅游</h1></span> </a>
        </header>
        <div class="down">
            <a   style="display: inline-block;">
                <img style="width: 58px; border: 3px solid #ddd; margin-top: -30px" src="http://202.97.207.34:8199/user.png">
            </a>
            <a    style="display: inline-block; margin-left: 10px; text-align: left;">
                <span style="font-size: 15px; display: inline-block; margin-left: 9px;" class=" name-caret">${emp_name}</span><br />
                <p style="display: inline-block;" id="clock3"></p>
            </a>
        </div>

        <div style="border-top:1px solid rgba(69, 74, 84, 0.7)"></div>

        <div class="menu">
            <ul id="menu">
                <li><a href="${ctx}/work/addEvent"><i class="lnr lnr-pencil"></i> <span>上报事件</span></a></li>
                <li><a href="${ctx}/work/zworkIndex"><i class="fa fa-file-text-o"></i> <span>组任务</span></a></li>
                <li><a href="${ctx}/work/gworkIndex"><i class="fa fa-file-text-o"></i> <span>个人任务</span></a></li>
                <li><a href="${ctx}/work/insertEvent"><i class="lnr lnr-pencil"></i> <span>提交事件流</span></a></li>
                <li><a href="${ctx}/work/queryAllEvent"><i class="lnr lnr-pencil"></i> <span>查询事件</span></a></li>
                <li id="menu-academico">
                    <a><i class="fa fa-table"></i> <span> 系统管理</span> <span class="fa fa-angle-right"
                                                                            style="float: right"></span></a>
                    <ul id="menu-academico-sub">
                        <li><a href="${ctx}/emp/empIndex">人员管理</a></li>
                        <li><a href="${ctx}/org/orgIndex">部门管理</a></li>
                        <li><a href="${ctx}/role/roleIndex">角色管理</a></li>
                        <li><a href="${ctx}/sys/grid">网格管理</a></li>
                    </ul>
                </li>
            </ul>
        </div>
    </div>
    <div class="clearfix"></div>
</div>
<form action="${ctx}/org/insertOrg" method="post">
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"
         style="display: none;">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close second" data-dismiss="modal" aria-hidden="true">×</button>
                </div>
                <div class="modal-body">
                    <div class="set-1">
                        <div class="graph-2 general">
                            <div class="grid-1" style=" margin: 0;">
                                <div class="form-body">
                                    <div class="form-horizontal">
                                        <div class="form-group">
                                            <label for="org_name" class="col-sm-3 control-label" style="margin-top: 0;">部门名称</label>
                                            <input type="hidden" id="org_id" name="org_id">
                                            <div class="col-sm-9">
                                                <input type="text" class="form-control1" id="org_name" placeholder=""
                                                       name="org_name" required="required">
                                            </div>
                                        </div>
                                    </div>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
                <div class="modal-footer">
                    <button type="submit" class="btn btn-default" onclick="add()">保存</button>
                    <button type="button" class="btn btn-default" data-dismiss="modal"  style="margin-bottom: 10px">关闭</button>

                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal-dialog -->
    </div>
</form>
<%@include file="../my_js_css/jsInclude.jsp" %>
</body>
<script>
    function add() {
        alert("保存成功")
    }

    function clearModel() {
        $("input").val("")
        $("#myModal").modal('show')
    }
    function edit(orgId) {
        $.getJSON('${ctx}/org/queryOrg', {"orgId": orgId}, function (result) {
            $("#org_id").val(result.org_id);
            $("#org_name").val(result.org_name);
        })
        $("#myModal").modal('show')
    }


    function del(orgId) {
        var r = confirm("如果删除将无法恢复，请问是否删除?")
        if (r == true) {
            $.getJSON('${ctx}/org/delOrg', {"orgId": orgId}, function (result) {
                alert("删除成功")
            })
        }
        else {
            alert("您已取消删除")
        }
    }
</script>
</html>